<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <!-- <el-form-item label="员工全局ID" prop="empId">
        <el-input
          v-model="queryParams.empId"
          placeholder="请输入员工全局ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="部门编号" prop="deptId">
        <el-input
          v-model="queryParams.deptId"
          placeholder="请输入部门编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="员工名称" prop="empName">
        <el-input
          v-model="queryParams.empName"
          placeholder="请输入员工名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="员工编号" prop="empNumber">
        <el-input
          v-model="queryParams.empNumber"
          placeholder="请输入员工编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> 
      </el-form-item>
        <el-form-item label="主管单位" prop="competentOrgList">
           <el-select
              v-model="queryParams.competentOrgList"
              clearable
              multiple
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="dict in competentOrgOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>

            <el-form-item label="在职状态" prop="incumbencyList">
            <el-select
              v-model="queryParams.incumbencyList"
              clearable
              multiple
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="dict in jobStatusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="人员类别" prop="personList">
            <el-select
              v-model="queryParams.personList"
               multiple
               clearable
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="dict in peopleTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
      <el-form-item label="状态" prop="userStatus">
              <el-select
              v-model="queryParams.userStatusList"
               multiple
               clearable
              size="small"
              style="width: 240px"
            >
              <el-option
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
            </el-select>
          </el-form-item>
     
          <el-form-item label="主管部门" prop="deptList">
          <treeselect
            v-model="queryParams.deptList"
            :multiple="true"
            :flat="true"
            :options="deptOptions"
             :default-expand-level="1"
            placeholder="选择部门"
          />
          </el-form-item>
        
       
          <!-- <el-form-item label="项目负责人" prop="empProjectLeader">
            <el-input
              v-model="queryParams.empProjectLeader"
              placeholder="请输入项目负责人"
              clearable
              size="small"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item> -->
      <!-- <el-form-item label="项目负责人全局ID" prop="empProjectLeaderId">
        <el-input
          v-model="queryParams.empProjectLeaderId"
          placeholder="请输入项目负责人全局ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="领款经办人全局ID" prop="empProjectPayeeId">
        <el-input
          v-model="queryParams.empProjectPayeeId"
          placeholder="请输入领款经办人全局ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="员工移动电话号" prop="empMobilePhone">
        <el-input
          v-model="queryParams.empMobilePhone"
          placeholder="请输入员工移动电话号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="公司邮箱" prop="empCompanyEmail">
        <el-input
          v-model="queryParams.empCompanyEmail"
          placeholder="请输入公司邮箱"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="证件号码" prop="empIdNumber">
        <el-input
          v-model="queryParams.empIdNumber"
          placeholder="请输入证件号码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别" prop="empSex">
        <el-select v-model="queryParams.empSex" placeholder="请选择性别" clearable size="small">
           <el-option
                  v-for="dict in sexOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="入职日期" prop="empEntryDate">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.empEntryDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择入职日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="离职日期" prop="empQuitDate">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.empQuitDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择离职日期">
        </el-date-picker>
      </el-form-item> -->
      <!-- <el-form-item label="在职状态编码" prop="empIncumbencyState">
        <el-input
          v-model="queryParams.empIncumbencyState"
          placeholder="请输入在职状态编码"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="主职" prop="partType">
        <el-select v-model="queryParams.partType" placeholder="请选择主职" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="员工编号有效性" prop="empNumberEffectiveness">
        <el-input
          v-model="queryParams.empNumberEffectiveness"
          placeholder="请输入员工编号有效性"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="人事资料有效期" prop="empDataValid">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.empDataValid"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择人事资料有效期">
        </el-date-picker>
      </el-form-item> -->
      <!-- <el-form-item label="人员类别ID" prop="empPersonnelType">
        <el-select v-model="queryParams.empPersonnelType" placeholder="请选择人员类别ID" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="HR中员工ID" prop="empIdCode">
        <el-input
          v-model="queryParams.empIdCode"
          placeholder="请输入HR中员工ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="是否项目负责人" prop="empJudgeProjectLeader">
           <el-select v-model="queryParams.empJudgeProjectLeader" placeholder="请选择性别" clearable size="small">
           <el-option
                  v-for="dict in leaderOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否项目领款经办人" prop="empJudgeProjectPayee">
           <el-select v-model="queryParams.empJudgeProjectPayee" placeholder="请选择" clearable size="small">
           <el-option
                  v-for="dict in leaderOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="hr的项目负责人编号" prop="empProjectLeader">
        <el-input
          v-model="queryParams.empProjectLeader"
          placeholder="请输入hr的项目负责人编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="hr的项目领款经办人编号" prop="empProjectPayee">
        <el-input
          v-model="queryParams.empProjectPayee"
          placeholder="请输入hr的项目领款经办人编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="同步标志" prop="syncFlag">
        <el-input
          v-model="queryParams.syncFlag"
          placeholder="请输入同步标志"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:user:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:user:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:user:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:user:export']"
        >导出</el-button>
      </el-col> -->
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange" :default-sort="{ prop: 'fieldSort', order: 'descending' }" @sort-change="tableSortChange">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
      <!-- <el-table-column label="用户ID" align="center" prop="id" :sort-orders="['ascending', 'descending']" sortable="custom"/> -->
      <el-table-column label="员工编号" align="center" prop="empNumber" :sort-orders="['ascending', 'descending']" sortable="custom"/>
      <el-table-column label="员工名称" align="center" prop="empName" :sort-orders="['ascending', 'descending']" sortable="custom"/>
      <el-table-column label="主管部门名称" align="center" prop="deptContent" :sort-orders="['ascending', 'descending']" sortable="custom"/>
      <el-table-column label="主管单位名称" align="center" prop="competentOrgContent" :sort-orders="['ascending', 'descending']" sortable="custom"/>
      <el-table-column label="在职状态" align="center" prop="incumbencyContent" :sort-orders="['ascending', 'descending']" sortable="custom"/>
      <el-table-column label="人员类别" align="center" prop="personTypeContent" :sort-orders="['ascending', 'descending']" sortable="custom"/>
      <el-table-column label="员工移动电话号" align="center" prop="empMobilePhone" :sort-orders="['ascending', 'descending']" sortable="custom"/>
      <el-table-column label="入职日期" align="center" prop="empEntryDate" width="180" :sort-orders="['ascending', 'descending']" sortable="custom">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.empEntryDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="离职日期" align="center" prop="empQuitDate" width="180" :sort-orders="['ascending', 'descending']" sortable="custom">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.empQuitDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="公司邮箱" align="center" prop="empCompanyEmail" :sort-orders="['ascending', 'descending']" sortable="custom"/> -->
      <!-- <el-table-column label="证件类型" align="center" prop="idTypeContent" :sort-orders="['ascending', 'descending']" sortable="custom"/> -->
      <!-- <el-table-column label="证件号码" align="center" prop="empIdNumber" :sort-orders="['ascending', 'descending']" sortable="custom"/> -->
      <!-- <el-table-column label="性别" align="center" prop="empSex" :sort-orders="['ascending', 'descending']" sortable="custom"> -->
        <!-- <template slot-scope="scope">
          <span>{{ statusSexFormat(scope.row.empSex) }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="在职状态编码" align="center" prop="empIncumbencyState" /> -->
      <!-- <el-table-column label="主职" align="center" prop="partType" /> -->
      <!-- <el-table-column label="员工编号有效性" align="center" prop="empNumberEffectiveness" /> -->
      <!-- <el-table-column label="员工编号有效性" align="center" prop="empIsvalidContent" :sort-orders="['ascending', 'descending']" sortable="custom"/> -->
      <!-- <el-table-column label="人事资料有效期" align="center" prop="empDataValid" width="180" :sort-orders="['ascending', 'descending']" sortable="custom"> -->
        <!-- <template slot-scope="scope">
          <span>{{ parseTime(scope.row.empDataValid, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="人员类别ID" align="center" prop="empPersonnelType" /> -->
      
      <!-- <el-table-column label="HR中员工ID" align="center" prop="empIdCode" /> -->
      <!-- <el-table-column label="HR部门ID" align="center" prop="deptIdCode" /> -->
      <!-- <el-table-column label="是否项目负责人" align="center" prop="empJudgeProjectLeader" :sort-orders="['ascending', 'descending']" sortable="custom">
        <template slot-scope="scope">
          <span>{{ statusLeaderFormat(scope.row.empJudgeProjectLeader) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否项目领款经办人" align="center" prop="empJudgeProjectPayee" :sort-orders="['ascending', 'descending']" sortable="custom">
        <template slot-scope="scope">
          <span>{{ statusLeaderFormat(scope.row.empJudgeProjectPayee) }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="hr的项目负责人编号" align="center" prop="empProjectLeader" >
        <template slot-scope="scope">
          <span>{{ scope.row.empProjectLeader }}</span>
        </template>
      </el-table-column>
      <el-table-column label="hr的项目领款经办人编号" align="center" prop="empProjectPayee" >
        <template slot-scope="scope">
          <span>{{ scope.row.empProjectPayee }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="同步标志" align="center" prop="syncFlag" /> -->
      <el-table-column label="状态" align="center" prop="userStatus" :sort-orders="['ascending', 'descending']" sortable="custom">
         <template slot-scope="scope">
          <span> {{statusFormat(scope.row.userStatus)}}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:user:edit']"
          >详情</el-button>
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:user:remove']"
          >删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改部门同步中间对话框
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="部门名称" prop="deptContent">
          <el-input v-model="form.deptContent" disabled />
        </el-form-item>
        <el-form-item label="员工名称" prop="empName">
          <el-input v-model="form.empName" disabled />
        </el-form-item>
        <el-form-item label="员工编号" prop="empNumber">
          <el-input v-model="form.empNumber" disabled />
        </el-form-item>
        <el-form-item label="员工移动电话号" prop="empMobilePhone">
          <el-input v-model="form.empMobilePhone" disabled />
        </el-form-item>
        <el-form-item label="公司邮箱" prop="empCompanyEmail">
          <el-input v-model="form.empCompanyEmail" placeholder="请输入公司邮箱" />
        </el-form-item>
        <el-form-item label="证件类型">
          <el-input v-model="form.idTypeContent" placeholder=""/>
        </el-form-item>
        <el-form-item label="证件号码" prop="empIdNumber">
          <el-input v-model="form.empIdNumber" placeholder="请输入证件号码" />
        </el-form-item>
        <el-form-item label="性别" prop="empSex">
          <el-select v-model="form.empSex" placeholder="请选择性别">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="入职日期" prop="empEntryDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.empEntryDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择入职日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="离职日期" prop="empQuitDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.empQuitDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择离职日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="主管单位名称">
          <el-input v-model="form.competentOrgContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="在职状态">
          <el-input v-model="form.incumbencyContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="主职" prop="partType">
          <el-select v-model="form.partType" placeholder="请选择主职">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="员工编号有效性">
          <el-input v-model="form.empIsvalidContent" placeholder="请输入员工编号有效性"/>
        </el-form-item>
        <el-form-item label="人事资料有效期" prop="empDataValid">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.empDataValid"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择人事资料有效期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="人员类别">
          <el-input v-model="form.personTypeContent" :min-height="192"/>
        </el-form-item>
        <el-form-item label="是否项目负责人" prop="empJudgeProjectLeader">
          <el-input v-model="form.empJudgeProjectLeader" placeholder="请输入是否项目负责人" />
        </el-form-item>
        <el-form-item label="是否项目领款经办人" prop="empJudgeProjectPayee">
          <el-input v-model="form.empJudgeProjectPayee" placeholder="请输入是否项目领款经办人" />
        </el-form-item>
        <el-form-item label="hr的项目负责人编号" prop="empProjectLeader">
          <el-input v-model="form.empProjectLeader" placeholder="请输入hr的项目负责人编号" />
        </el-form-item>
        <el-form-item label="hr的项目领款经办人编号" prop="empProjectPayee">
          <el-input v-model="form.empProjectPayee" placeholder="请输入hr的项目领款经办人编号" />
        </el-form-item>
        <el-form-item label="同步标志" prop="syncFlag">
          <el-input v-model="form.syncFlag" placeholder="请输入同步标志" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancel">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div> -->
  
    <!-- 添加或修改部门同步中间对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" label-width="138px">
        <el-form-item label="主管单位名称">
          <span type="text">{{form.competentOrgContent}}</span>
        </el-form-item>
        <el-form-item label="部门名称" prop="deptContent">
           <span type="text">{{form.deptContent}}</span>
        </el-form-item>
        <el-form-item label="员工名称" prop="empName">
          <span type="text">{{form.empName}}</span>
        </el-form-item>
        <el-form-item label="员工编号" prop="empNumber">
          <span type="text">{{form.empNumber}}</span>
        </el-form-item>
        <el-form-item label="员工移动电话号" prop="empMobilePhone">
          <span type="text">{{form.empMobilePhone}}</span>
        </el-form-item>
        <el-form-item label="公司邮箱" prop="empCompanyEmail">
          <span type="text">{{form.empCompanyEmail}}</span>
        </el-form-item>
        <el-form-item label="证件类型">
          <span type="text">{{form.idTypeContent}}</span>
        </el-form-item>
        <el-form-item label="证件号码" prop="empIdNumber">
          <span type="text">{{form.empIdNumber}}</span>
        </el-form-item>
        <el-form-item label="性别" prop="empSex">
          <span type="text">{{statusSexFormat(form.empSex)}}</span>
        </el-form-item>
        <el-form-item label="入职日期" prop="empEntryDate">
          <span type="text">{{ parseTime(form.empEntryDate, '{y}-{m}-{d}')}}</span>
        </el-form-item>
        <el-form-item label="离职日期" prop="empQuitDate">
          <span type="text">{{ parseTime(form.empQuitDate, '{y}-{m}-{d}')}}</span>
        </el-form-item>
        <el-form-item label="在职状态">
          <span type="text">{{form.incumbencyContent}}</span>
        </el-form-item>
        <el-form-item label="主职" prop="partType">
          <span type="text">{{form.partType}}</span>
        </el-form-item>
        <el-form-item label="员工编号有效性">
          <span type="text">{{form.empIsvalidContent}}</span>
        </el-form-item>
        <el-form-item label="人事资料有效期" prop="empDataValid">
           <span type="text">{{ parseTime(form.empDataValid, '{y}-{m}-{d}')}}</span>
        </el-form-item>
        <el-form-item label="人员类别">
          <span type="text">{{form.personTypeContent}}</span>
        </el-form-item>
        <el-form-item label="是否项目负责人" prop="empJudgeProjectLeader">
          <span type="text">{{statusLeaderFormat(form.empJudgeProjectLeader)}}</span>
        </el-form-item>
        <el-form-item label="是否项目领款经办人" prop="empJudgeProjectPayee">
          <span type="text">{{statusLeaderFormat(form.empJudgeProjectPayee)}}</span>
        </el-form-item>
        <el-form-item label="项目负责人" prop="empProjectLeader">
          <span type="text">{{form.empProjectLeader}}</span>
        </el-form-item>
        <el-form-item label="项目领款经办人" prop="empProjectPayee">
          <span type="text">{{form.empProjectPayee}}</span>
        </el-form-item>
        <!-- <el-form-item label="同步标志" prop="syncFlag">
          <span type="text">{{form.syncFlag}}</span>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="cancel">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listUser, getUser, delUser, addUser, updateUser, exportUser,selectUser,selectDept } from "@/api/system/hr";
import Editor from '@/components/Editor';
import { treeselect as deptTreeselect } from "@/api/system/dept";
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
  name: "User",
  components: {
    Editor,Treeselect
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 部门同步中间表格数据
      userList: [],
      leaderOptions:[],
      peopleTypeOptions:[],
      jobStatusOptions:[],
      statusOptions:[],
      competentOrgOptions:[],
      sexOptions:[],
      // 默认展示部门树层
      treeExpandData: [] ,
      deptOptions:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        empId: null,
        deptId: null,
        empName: null,
        empNumber: null,
        empProjectLeaderId: null,
        empProjectPayeeId: null,
        empMobilePhone: null,
        empCompanyEmail: null,
        idTypeContent: null,
        empIdNumber: null,
        empSex: null,
        empEntryDate: null,
        empQuitDate: null,
        competentOrgContent: null,
        incumbencyContent: null,
        empIncumbencyState: null,
        partType: null,
        empNumberEffectiveness: null,
        empIsvalidContent: null,
        empDataValid: null,
        empPersonnelType: null,
        personTypeContent: null,
        empIdCode: null,
        deptIdCode: null,
        empJudgeProjectLeader: null,
        empJudgeProjectPayee: null,
        empProjectLeader: null,
        empProjectPayee: null,
        syncFlag: null,
        competentOrgList:null,
        deptList:null,
        incumbencyList:null,
        personList:null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        empId: [
          { required: true, message: "员工全局ID不能为空", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "部门编号不能为空", trigger: "blur" }
        ],
        empName: [
          { required: true, message: "员工名称不能为空", trigger: "blur" }
        ],
        empNumber: [
          { required: true, message: "员工编号不能为空", trigger: "blur" }
        ],
        empIdCode: [
          { required: true, message: "HR中员工ID不能为空", trigger: "blur" }
        ],
      },
      defaultProps: {
        children: "children",
        label: "label"
      },
    };
  },
  watch: {
    deptOptions: {
		handler () {
			//我这里默认展开一级, 指定几级就往里遍历几层取到 id 就可以了
			this.deptOptions.forEach(item => {
        this.treeExpandData.push(item.id)
      })
		  },
		deep: true
	  },
  },
  created() {
    this.getList();
    this.getDicts("sys_user_sex").then(response => {
      this.sexOptions = response.data;
    });	
    this.getDicts("portal_is_project_leader").then(response => {
      this.leaderOptions = response.data;
    });
    this.getDicts("portal_job_status").then((response) => {
      this.jobStatusOptions = response.data;
    });
    this.getDicts("portal_people_type").then((response) => {
      this.peopleTypeOptions = response.data;
    });
     this.getDicts("competent_org_options").then((response) => {
      this.competentOrgOptions = response.data;
    });
   this.getDicts("sys_hr_status").then(response => {
      this.statusOptions = response.data;
    });
    this.getDeptTreeselect();
  },
  methods: {
    /** 查询部门同步中间列表 */
    getList() {
      this.loading = true;
      listUser(this.queryParams).then(response => {
        this.userList = response.rows;
        console.log(this.userList)
        this.total = response.total;
        this.loading = false;
      });
    },
        /** 查询部门树结构 */
    getDeptTreeselect() {
      deptTreeselect().then(response => {
        this.deptOptions = response.data;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        empId: null,
        deptId: null,
        empName: null,
        empNumber: null,
        empProjectLeaderId: null,
        empProjectPayeeId: null,
        empMobilePhone: null,
        empCompanyEmail: null,
        idTypeContent: null,
        empIdNumber: null,
        empSex: null,
        empEntryDate: null,
        empQuitDate: null,
        competentOrgContent: null,
        incumbencyContent: null,
        empIncumbencyState: null,
        partType: null,
        empNumberEffectiveness: null,
        empIsvalidContent: null,
        empDataValid: null,
        empPersonnelType: null,
        personTypeContent: null,
        empIdCode: null,
        deptIdCode: null,
        empJudgeProjectLeader: null,
        empJudgeProjectPayee: null,
        empProjectLeader: null,
        empProjectPayee: null,
        syncFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        deptContent:null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.competentOrgList=null;
      this.queryParams.deptList=null;
      this.queryParams.incumbencyList=null;
      this.queryParams.personList=null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加部门同步中间";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getUser(id).then(response => {
        this.form = response.data;
        this.asyncGetUser();
        console.log(this.form)
        this.open = true;
        this.title = "HR用户详情";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateUser(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addUser(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除部门同步中间编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delUser(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有部门同步中间数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportUser(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    },
    async asyncGetUser(){
      let projectLeader = await selectUser(this.form.empProjectLeader);
      let projectPayee = await selectUser(this.form.empProjectPayee);
      if(projectLeader.data)(
        this.form.empProjectLeader =projectLeader.data.empName
      )
     if(projectPayee.data)(
       this.form.empProjectPayee =projectPayee.data.empName
      )
    },
    statusSexFormat(type){
      let option=this.sexOptions;
      for (let i = 0; i < option.length; i++) {
        if (option[i].dictValue==type){
           return option[i].dictLabel;
        }
      }
    },
    statusLeaderFormat(type){
      let option=this.leaderOptions;
      for (let i = 0; i < option.length; i++) {
        if (option[i].dictValue==type){
           return option[i].dictLabel;
        }
      }
    },
    tableSortChange(column) {
      this.queryParams.pageNum = 1;
      if (column.order === "descending") {
        this.queryParams.sortBy = column.prop;
        this.queryParams.order = "desc";
      } else {
        this.queryParams.sortBy = column.prop;
        this.queryParams.order = "asc";
      }
      this.getList();
    },
     statusFormat(type){
      let option=this.statusOptions;
        for (let i = 0; i < option.length; i++) {
        if (option[i].dictValue==type){
          return option[i].dictLabel;
        }
      }
    },
  }
};
</script>
<style>
.vue-treeselect{
    height: 20px;
    width: 450px !important;
  }
  .vue-treeselect .vue-treeselect__control{
    height: 28px !important;
    
  }
  .vue-treeselect__placeholder{
    line-height: 28px;
    font-size: 14px;
  }
  .vue-treeselect input{
    font-size: 16px;
  }
</style>